//
//  AuctionModels.swift
//  LeGou
//
//  Created by lxm on 2022/10/15.
//

import Foundation
struct AuctionModels {
    class Order : HandyJSON {
        required init(){}
        /// 期数
        var ahCount: Int = 0
        /// 竞购商品记录id
        var ahGoodsRecordId: Int = 0
        /// 出价编号
        var bidNo = ""
        /// 已出价人数
        var bidPeopleNum: Int = 0
        /// 出价状态0 出局 1领先
        var bidState: Int = 0
        var createTime = ""
        var currentPrice: Int = 0
        var currentViewer: Int = 0
        var frequency: Int = 0
        var image = ""
        var joinShare: Int = 0
        var nowAmount: Int = 0
        var state: Int = 0
        var storeName = ""
    }
    
    class Acitivity : HandyJSON {
        required init(){}
        /// 期数
        var endTime = 0
        var startTime = 0
        var state : AcitivityState = .wait
        var id = 0
    }
    
    enum AcitivityState : Int, HandyJSONEnum {
        case wait = 0
        case process = 1
        case over = 2
        
        func des() -> String {
            switch self {
                case .wait: return "即将开始"
                case .process: return "竞购中"
                case .over: return "已结束"
            }
        }
    }
    
    enum BidState : Int, HandyJSONEnum {
        case wait = 0
        case process = 1
        case success = 2
        case toNext = 3
        case soldOut = 4
        case deleted = 5
        
        func des() -> String {
            switch self {
                case .wait: return "即将开始"
                case .process: return "竞购中"
                case .success: return "已结束"
                case .toNext: return "已流拍"
                case .soldOut: return "已下架"
                case .deleted: return "已删除"
            }
        }
        
        func desForDetail() -> (String, UIColor) {
            switch self {
                case .wait: return ("即将开始", Style.mainColor)
                case .process: return ("正在竞购", UIColor.zm.color333333())
                case .success: return ("竞购已结束", UIColor.zm.color999999())
            default :
                return ("竞购已结束", UIColor.zm.color999999())
            }
        }
    }
    
    struct Goods : HandyJSON {
        /// 已出价人数
        var bidCount: Int = 0
        ///  竞购状态
        var bidState : BidState = .wait
        /// 当前出价
        var currentBid = 0.0
        /// 当前期数
        var currentRound: Int = 0
        /// id
        var id: Int = 0
        /// 商品列表图
        var image = ""
        /// 你参与次数
        var joinTime: Int = 0
        /// 市场价
        var marketPrice = 0.0
        /// 最高赚
        var maxReward = 0.0
        /// 商品名称
        var name = ""
        /// 当前期数0 = 未开始 2 = 竞购中 3 = 已结束
        var state : AcitivityState = .wait
        /// 围观人数
        var viewer: Int = 0
        
        var startPrice = 0.0
        
        var getcurrentMoney : Double {
            get {
                return currentBid > 0 ? currentBid : startPrice
            }
        }
    }
 
    struct GoodsRecord  : HandyJSON {
        var activityId: Int = 0
        var ahCount: Int = 0
        var ahProductId: Int = 0
        var bail = 0.0
        var costPrice: Int = 0
        var createTime = ""
        var currentPrice: Int = 0
        var currentUserId: Int = 0
        var currentViewer: Int = 0
        var endTime = ""
        var finalPaid: Int = 0
        var id: Int = 0
        var joinShare: Int = 0
        var levelShare: Int = 0
        var markPrice = 0.0
        var maxJoin: Int = 0
        var maxPrice = 0.0
        var productId: Int = 0
        var profitShare: Int = 0
        var showId = ""
        var startPrice = 0.0
        var startTime = ""
        var state: Int = 0
        var stepPrice = 0.0
    }

    struct ProductInfo : HandyJSON {
        var activity = ""
        var addTime: Int = 0
        var barCode = ""
        var browse: Int = 0
        var cateId = ""
        var codePath = ""
        var commission: Int = 0
        var content = ""
        var cost: Int = 0
        var downloadLink = ""
        var ficti: Int = 0
        var flatPattern = ""
        var giveActivity: Int = 0
        var giveIntegral: Int = 0
        var id: Int = 0
        var image = ""
        var isBargain: Bool = false
        var isBenefit: Bool = false
        var isBest: Bool = false
        var isDel: Bool = false
        var isGood: Bool = false
        var isHot: Bool = false
        var isNew: Bool = false
        var isPostage: Bool = false
        var isRecycle: Bool = false
        var isSeckill: Bool = false
        var isShow: Bool = false
        var isSub: Bool = false
        var keyword = ""
        var merId: Int = 0
        var merUse: Bool = false
        var otPrice = 0.0
        var password = ""
        var postage: Int = 0
        var price: Int = 0
        var sales: Int = 0
        var sliderImage = ""
        var sort: Int = 0
        var soureLink = ""
        var specType: Bool = false
        var stock: Int = 0
        var storeInfo = ""
        var storeName = ""
        var tempId: Int = 0
        var type: Int = 0
        var unitName = ""
        var videoLink = ""
        var vipPrice: Int = 0
    }

    struct RecordResponse : HandyJSON {
        var bidState: Int = 0
        var cityName = ""
        var createTime = ""
        var showId = ""
        var stepAmount = 0.0
    }
    
    struct ChallengerDataResponse : HandyJSON {
        var avatar = ""
        var challengerState = 0
        var currentPrice = 0.0
        var gainActivity = 0.0
        var nickname = ""
        var rewardMoney = 0.0
        var surplusPrice = 0.0
    }
    

    class AuctionDetail : HandyJSON {
        required init(){}
        // 用户竞购状态：0未出价 1已出价且出局 2已出价且领先 3竞拍成功未中 4竞拍成功已中
        var ahState: Int = 0
        var bail = 0.0
        var beatNum: Int = 0
        var currentPrice = 0.0
        var currentViewer: Int = 0
        var finalPaid: Int = 0
        var joinShare = 0.0
        var offerNum: Int = 0
        var rewardMoney = ""
        var state : BidState = .wait
        var surplusPrice = 0.0
        var orderId = 0
        var goodsRecord = GoodsRecord()
        var productInfo = ProductInfo()
        var recordResponse = RecordResponse()
        // 擂主信息
        var challengerDataResponse : ChallengerDataResponse?
        
        // 当前价
        var getcurrentMoney : Double {
            get {
                return currentPrice > 0 ? currentPrice : goodsRecord.startPrice
            }
        }
    }
    
   
    
    struct BidRecord : HandyJSON {
        // 出价状态：0出局 1领先
        var bidState: Int = 0
        var cityName = ""
        var createTime = ""
        var showId = ""
        var stepAmount = 0.0
        var avatar = ""
        
        var bidStateStr : String {
            get {
                if bidState == 0 {
                    return "出局"
                } else {
                    return "领先"
                }
            }
        }
    }
    
    struct CompoundResult : HandyJSON {
        var extraRewardAmount: Int = 0
        var giveQuantity: Int = 0
        var refundAmount: Int = 0
        var rewardAmount = 0.0
        var rewardRangeEnd: Int = 0
        var rewardRangeStart: Int = 0
        var orderId = ""
    }
    
    enum AutoState : Int, HandyJSONEnum {
        case signed = 0
        case process = 1
        case stop = 2
        case over = 3
        
        func des() -> String {
            switch self {
                case .signed: return "已报名"
                case .process: return "竞购中"
                case .stop: return "竞购中断"
                case .over: return "已结束"
            }
        }
    }
    
    class AutoAutionDetail : HandyJSON {
        required init(){}
        var productInfo = ProductInfo()
        var bail = 0.0
        var conflateCount = 0
        var endMillis = 0
        var giveCount = 0
        var enrollCount = 0
        var interruptType = 0
        var joinCount = 0
        var startMillis = 0
        var startPrice = 0.0
        var state : AutoState? = nil
        var stepPrice = 0.0
        var dayConflateCount = 0
        
        func desTitle() -> String {
            guard let s = state else {return "可报名"}
            switch s {
                case .signed: return "已报名"
                case .process: return "进行中"
                case .stop: return "进行中"
                case .over: return "已结束"
            }
        }
    }
    
    struct ConflateRecord : HandyJSON {
        // 出价状态：0出局 1领先
        var amount = 0.0
        var cityName = ""
        var conflateTime = ""
        var showId = ""
    }
}

